{% extends "base.html" %}

{% block content %}
<div class="card">
    <div class="card-header d-flex justify-content-between align-items-center">
        <h3 class="card-title mb-0">离职员工详情</h3>
        <div>
            <button type="button" class="btn btn-danger btn-sm" data-bs-toggle="modal" data-bs-target="#deleteModal">
                删除员工
            </button>
        </div>
    </div>
    <div class="card-body">
        <!-- 基本信息部分 -->
        <div class="row mb-4">
            <div class="col-12">
                <h5 class="mb-3">基本信息</h5>
                <div class="row">
                    <div class="col-md-6">
                        <table class="table">
                            <tr>
                                <th style="width: 120px;">姓名：</th>
                                <td>{{ employee.name }}</td>
                            </tr>
                            <tr>
                                <th>部门：</th>
                                <td>{{ employee.department }}</td>
                            </tr>
                            <tr>
                                <th>职位：</th>
                                <td>{{ employee.position }}</td>
                            </tr>
                        </table>
                    </div>
                    <div class="col-md-6">
                        <table class="table">
                            <tr>
                                <th style="width: 120px;">身份证号：</th>
                                <td>{{ employee.id_card }}</td>
                            </tr>
                            <tr>
                                <th>手机号：</th>
                                <td>{{ employee.phone }}</td>
                            </tr>
                            <tr>
                                <th>入职日期：</th>
                                <td>
                                    {% if employee.hire_date %}
                                        {% if employee.hire_date is string %}
                                            {{ employee.hire_date }}
                                        {% else %}
                                            {{ employee.hire_date.strftime('%Y-%m-%d') }}
                                        {% endif %}
                                    {% else %}
                                        -
                                    {% endif %}
                                </td>
                            </tr>
                            <tr>
                                <th>离职日期：</th>
                                <td>
                                    {% if employee.resign_date %}
                                        {% if employee.resign_date is string %}
                                            {{ employee.resign_date }}
                                        {% else %}
                                            {{ employee.resign_date.strftime('%Y-%m-%d') }}
                                        {% endif %}
                                    {% else %}
                                        -
                                    {% endif %}
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <!-- 证件信息部分 -->
        <div class="row mb-4">
            <div class="col-12">
                <h5 class="mb-3">证件信息</h5>
                <!-- 身份证信息 -->
                <div class="row mb-4">
                    <div class="col-md-6">
                        <label class="form-label">身份证正面：</label>
                        {% if employee.id_card_front %}
                            <div>
                                <img src="{{ url_for('static', filename=employee.id_card_front) }}" alt="身份证正面" class="img-thumbnail" style="max-height: 200px;">
                            </div>
                        {% else %}
                            <p class="text-muted">未上传</p>
                        {% endif %}
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">身份证反面：</label>
                        {% if employee.id_card_back %}
                            <div>
                                <img src="{{ url_for('static', filename=employee.id_card_back) }}" alt="身份证反面" class="img-thumbnail" style="max-height: 200px;">
                            </div>
                        {% else %}
                            <p class="text-muted">未上传</p>
                        {% endif %}
                    </div>
                </div>

                <!-- 学历学位证书 -->
                <div class="row mb-4">
                    <div class="col-md-6">
                        <label class="form-label">学历证书：</label>
                        {% if employee.diploma %}
                            {% if employee.diploma.endswith('.pdf') %}
                                <div>
                                    <a href="{{ url_for('static', filename=employee.diploma) }}" target="_blank" class="btn btn-sm btn-info">查看PDF</a>
                                </div>
                            {% else %}
                                <div>
                                    <img src="{{ url_for('static', filename=employee.diploma) }}" alt="学历证书" class="img-thumbnail" style="max-height: 200px;">
                                </div>
                            {% endif %}
                        {% else %}
                            <p class="text-muted">未上传</p>
                        {% endif %}
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">学位证书：</label>
                        {% if employee.degree %}
                            {% if employee.degree.endswith('.pdf') %}
                                <div>
                                    <a href="{{ url_for('static', filename=employee.degree) }}" target="_blank" class="btn btn-sm btn-info">查看PDF</a>
                                </div>
                            {% else %}
                                <div>
                                    <img src="{{ url_for('static', filename=employee.degree) }}" alt="学位证书" class="img-thumbnail" style="max-height: 200px;">
                                </div>
                            {% endif %}
                        {% else %}
                            <p class="text-muted">未上传</p>
                        {% endif %}
                    </div>
                </div>
            </div>
        </div>

        <!-- 其他证书部分 -->
        {% if employee.other_certificates %}
        <div class="row">
            <div class="col-12">
                <h5 class="mb-3">其他证书</h5>
                <div class="row">
                    {% for cert in employee.other_certificates %}
                    <div class="col-md-6 mb-4">
                        <div class="border rounded p-3">
                            <h6 class="mb-3">{{ cert.name }}</h6>
                            {% if cert.image %}
                                {% if cert.image.endswith('.pdf') %}
                                    <a href="{{ url_for('static', filename=cert.image) }}" target="_blank" class="btn btn-sm btn-info">查看PDF</a>
                                {% else %}
                                    <div>
                                        <img src="{{ url_for('static', filename=cert.image) }}" alt="{{ cert.name }}" class="img-thumbnail" style="max-height: 200px;">
                                    </div>
                                {% endif %}
                            {% else %}
                                <p class="text-muted">未上传</p>
                            {% endif %}
                        </div>
                    </div>
                    {% endfor %}
                </div>
            </div>
        </div>
        {% endif %}
    </div>
</div>

<!-- 删除确认模态框 -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="deleteModalLabel">确认删除</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                确定要删除离职员工 {{ employee.name }} 吗？此操作不可恢复。
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                <a href="{{ url_for('employee.delete_resigned_employee', id=employee.id) }}" class="btn btn-danger">确认删除</a>
            </div>
        </div>
    </div>
</div>
{% endblock %} 